package tec;

import tec.EtatPassager;

public class PassagerStandard {
    private final String nom;
    private final int destination;
    private EtatPassager monEtat;

    private final static EtatPassager DEHORS = new EtatPassager(Etat.DEHORS) ;
    private final static EtatPassager ASSIS = new EtatPassager(Etat.ASSIS) ;
    private final static EtatPassager DEBOUT = new EtatPassager(Etat.DEBOUT) ;
    
    
    public PassagerStandard(String nom, int destination){
	this.nom = nom;
	this.destination = destination;
	monEtat = DEHORS;
    }

    

    
    public PassagerStandard(String nom, int destination, String etat) {
	this.nom = nom;
	this.destination = destination;
	if(etat == "assis"){
	    monEtat = ASSIS;
	}
	else{ 
	    if(etat == "dehors"){
		monEtat = DEHORS;
	    }
	    else{
		if(etat == "debout"){
		    monEtat = DEBOUT;
		}
		else{
		    monEtat = DEHORS;   //a revoir
		}
		
	    }
	}
	
	
    }

    public String nom() {
	return nom;
    }

    public boolean estDehors() {
	return monEtat.estExterieur();
    }

    public boolean estAssis(){
	return monEtat.estAssis();
    }

    public boolean estDebout() {
	return monEtat.estDebout();
    }

    public void accepterSortie() {
	monEtat = DEHORS;
    }

    public void accepterPlaceAssise() {
	monEtat = ASSIS;
	
    }

    public void accepterPlaceDebout() {
	monEtat = DEBOUT;
    }

    public void nouvelArret(Autobus bus, int numeroArret) {
	if(destination <= numeroArret){
	    bus.demanderSortie(this);
	}
    }

    public void monterDans(Autobus t) { 
	if(t.aPlaceAssise())
	    t.demanderPlaceAssise(this);
	else{
	    if(t.aPlaceDebout())
		t.demanderPlaceDebout(this);
	}
    }
    @Override
    public String toString() {
	
	return nom() + " " + monEtat.toString();
    }
}
